package com.duke.payphone.factory;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import com.duke.payphone.Global;


/**
 * class responsible for creating map objects for various applications
 * 
 * maps are used as communication objects between the server and app
 * 
 * each map must have a function name (and a user name) based on the function
 * that it is trying to perform; basically we are using maps to make requests
 * between the app and the server
 * 
 * @author Michael
 * 
 */
public class MapFactory {

    // private static Map<String, Serializable> myTransmitMap;
    // private static Map<String, Serializable> myReceiveMap;

    /**
     * Creates a map to receive server response
     * 
     * @return
     */
    public static Map<String, Serializable> createReceiveMap () {
        Map<String, Serializable> myReceiveMap = new HashMap<String, Serializable>();

        myReceiveMap.put("server", "invalid");
        myReceiveMap.put("session", "invalid");
        myReceiveMap.put("result", "invalid");

        return myReceiveMap;
    }

    /**
     * Creates map to transmit to server
     * 
     * @param function
     * @return
     */
    public static Map<String, Serializable> createTransmitMap (String function) {
        Map<String, Serializable> myTransmitMap = new HashMap<String, Serializable>();

        myTransmitMap.put("function", function);
        myTransmitMap.put("sessionid", Global.sessionid);
        myTransmitMap.put("username", Global.username);

        return myTransmitMap;
    }

}
